import { IPSSysBIAggColumn } from './ipssys-biagg-column';
import { IPSSysBIAggTable } from './ipssys-biagg-table';
import { IPSSysBICubeDimension } from './ipssys-bicube-dimension';
import { IPSSysBICubeMeasure } from './ipssys-bicube-measure';
import { IPSDEField } from '../dataentity/defield/ipsdefield';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSSysBIAggColumnImpl extends PSModelObjectImpl implements IPSSysBIAggColumn {
  get codeName(): string {
    return this.M.codeName;
  }

  get columnTag(): string {
    return this.M.columnTag;
  }

  get columnTag2(): string {
    return this.M.columnTag2;
  }

  get columnType(): 'MEASURE' | 'DIMENSION' | 'USER' {
    return this.M.columnType;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psdefield: IPSDEField | null = null;

  getPSDEField(): IPSDEField | null {
    if (this.psdefield != null) return this.psdefield;
    const value = this.M.getPSDEField;
    if (value == null) {
      return null;
    }
    const ipssysbiaggtable = this.getParentPSModelObject('bi.IPSSysBIAggTable') as IPSSysBIAggTable;
    if (ipssysbiaggtable != null) {
      this.psdefield = ipssysbiaggtable.getPSDataEntityMust().findPSDEField(value);
    }
    return this.psdefield;
  }

  get psDEField(): IPSDEField | null {
    return this.getPSDEField();
  }

  getPSDEFieldMust(): IPSDEField {
    const value = this.getPSDEField();
    if (value == null) {
      throw new Error('未指定实体属性');
    }
    return value;
  }

  protected pssysbicubedimension: IPSSysBICubeDimension | null = null;

  getPSSysBICubeDimension(): IPSSysBICubeDimension | null {
    if (this.pssysbicubedimension != null) return this.pssysbicubedimension;
    const value = this.M.getPSSysBICubeDimension;
    if (value == null) {
      return null;
    }
    const ipssysbiaggtable = this.getParentPSModelObject('bi.IPSSysBIAggTable') as IPSSysBIAggTable;
    if (ipssysbiaggtable != null) {
      this.pssysbicubedimension = ipssysbiaggtable.getPSSysBICubeMust().findPSSysBICubeDimension(value);
    }
    return this.pssysbicubedimension;
  }

  get psSysBICubeDimension(): IPSSysBICubeDimension | null {
    return this.getPSSysBICubeDimension();
  }

  getPSSysBICubeDimensionMust(): IPSSysBICubeDimension {
    const value = this.getPSSysBICubeDimension();
    if (value == null) {
      throw new Error('未指定立方体维度');
    }
    return value;
  }

  protected pssysbicubemeasure: IPSSysBICubeMeasure | null = null;

  getPSSysBICubeMeasure(): IPSSysBICubeMeasure | null {
    if (this.pssysbicubemeasure != null) return this.pssysbicubemeasure;
    const value = this.M.getPSSysBICubeMeasure;
    if (value == null) {
      return null;
    }
    const ipssysbiaggtable = this.getParentPSModelObject('bi.IPSSysBIAggTable') as IPSSysBIAggTable;
    if (ipssysbiaggtable != null) {
      this.pssysbicubemeasure = ipssysbiaggtable.getPSSysBICubeMust().findPSSysBICubeMeasure(value);
    }
    return this.pssysbicubemeasure;
  }

  get psSysBICubeMeasure(): IPSSysBICubeMeasure | null {
    return this.getPSSysBICubeMeasure();
  }

  getPSSysBICubeMeasureMust(): IPSSysBICubeMeasure {
    const value = this.getPSSysBICubeMeasure();
    if (value == null) {
      throw new Error('未指定立方体指标');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cls(): string {
    return 'PSSysBIAggColumnImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'bi.IPSBIAggColumn' || cls == 'bi.IPSSysBIAggColumn') return true;
    return super.instanceof(cls);
  }
}
